package com.xhtt.modules.app.controller.reportform;

import com.xhtt.common.utils.Constant;
import com.xhtt.common.utils.R;
import com.xhtt.modules.app.annotation.Login;
import com.xhtt.modules.app.annotation.LoginUser;
import com.xhtt.modules.sys.entity.SysUserEntity;
import com.xhtt.modules.task.model.report.TaskForRankingModel;
import com.xhtt.modules.task.model.report.TaskForSelfModel;
import com.xhtt.modules.task.model.report.TaskForTeamModel;
import com.xhtt.modules.task.model.report.TaskForTeamUserModel;
import com.xhtt.modules.task.service.TaskAllService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * 统计分析-app计划任务
 **/

@RestController
@RequestMapping(value = "app/report/task")
@Api(value = "统计分析-app计划任务", tags = "统计分析-app计划任务")
public class AppTaskReportController {
    @Autowired
    private TaskAllService taskAllService;

    @GetMapping(value = "/taskForTeam")
    @ApiOperation("班组数量统计分析")
    @Login
    public R taskForTeam(@RequestParam Map<String, Object> params) {
        List<TaskForTeamModel> result = taskAllService.taskForTeam(params);
        return R.ok().put(Constant.DATA, result);
    }

    @GetMapping(value = "/taskForTeamUser")
    @ApiOperation("每组人员数量统计分析")
    @Login
    public R taskForTeamUser(@RequestParam Map<String, Object> params, @ApiIgnore @LoginUser SysUserEntity user) {
        params.put("teamId", user.getTeamId());
        List<TaskForTeamUserModel> result = taskAllService.taskForTeamUser(params);
        return R.ok().put(Constant.DATA, result);
    }

    @GetMapping(value = "/taskForSelf")
    @ApiOperation("个人数量统计分析")
    @Login
    public R taskForSelf(@RequestParam Map<String, Object> params, @ApiIgnore @LoginUser SysUserEntity user) {
        params.put("userId", user.getUserId());
        List<TaskForSelfModel> result = taskAllService.taskForSelf(params);
        return R.ok().put(Constant.DATA, result);
    }

    @GetMapping(value = "/taskForRanking")
    @ApiOperation("任务时间排行榜")
    @Login
    public R taskForRanking() {
        List<TaskForRankingModel> result = taskAllService.taskForRanking();
        return R.ok().put(Constant.DATA, result);
    }

}
